/**
 * 
 * @param target 对于静态属性来说值是类，对于实例属性来说值是类的原型对象
 * @param propertyKey 属性名
 */

function Demo(target: object, propertyKey: string) {
    console.log(target, propertyKey)
}

class Person {
    @Demo name: string
    @Demo age: number
    @Demo static school: string
    constructor(name: string, age: number) {
        this.name = name
        this.age = age
    }
}

/**
 * 属性遮蔽
 * 
 */

class Person1 {
    name: string
    age: number
    constructor(name: string, age: number) {
        this.name = name
        this.age = age
    }
}
let value = 130
Object.defineProperty(Person.prototype, 'age', {
    get() {
        return value
    },
    set(val) {
        value = val
    }
})

// 产生属性遮蔽问题
const p1 = new Person('张三', 18)
// 类上的age和prototype里面的age都为18

console.log(p1)